<?php
if (!defined('ipos')) die("Please contact Y!m: ichphien_pro or Email: ichphien_pro@yahoo.com.");
if($levelTL != 3) {
	die("Bạn không đủ quyền để truy cập trang này!");
}
// add temp
if($mode == "add") {
	if($_POST['submit'])	{
		$danhmucten 		 = stripslashes(trim(urldecode($_POST['cat_name'])));
		$danhmucten_kd		 = replace($danhmucten);
		$danhmucstt 	     = stripslashes(trim(urldecode($_POST['cat_stt'])));
		if($cat_name && $cat_stt) {
			$db->dbinstall("category","danhmucten,danhmucten_kd,danhmucstt","'$danhmucten','$danhmucten_kd','$danhmucstt'");
			header("Location: index.php?ipos=category");
		}
	}
	include_once("./code/php/html_category.php");
}
//edit temp
elseif($mode == "edit") {
	$category	=	$db->database("danhmucten,danhmucstt","category","danhmucid = '$ipid'");
	if($_POST['submit'])	{
		$danhmucten 		 = stripslashes(trim(urldecode($_POST['cat_name'])));
		$danhmucten_kd		 = replace($danhmucten);
		$danhmucstt 	     = stripslashes(trim(urldecode($_POST['cat_stt'])));
		if($danhmucten && $danhmucstt) {
			$db->dbupdate("category","danhmucten = '$danhmucten',danhmucten_kd = '$danhmucten_kd',danhmucstt = '$danhmucstt'","danhmucid = '$ipid'");
			header("Location: index.php?ipos=category");
		}
	}
	include_once("./code/php/html_category.php");
}
// delete
elseif($mode == "delete") {
	if($ipid) {
		$db->dbdelete("category","danhmucid = '$ipid'");
		header("Location: index.php?ipos=category");
	}
}
// list temp
else {
	include_once("./code/php/html_category_list.php");
}
?>